package hero

//
//import "time"
//
//type HeroLogic struct {
//	dao *HeroDao
//}
//
//func NewHeroLogic() *HeroLogic {
//	return &HeroLogic{
//		dao: &HeroDao{},
//	}
//}
//
//// GetHeroes retrieves heroes by user ID
//func (h *HeroLogic) GetHeroes(uid string) ([]map[string]interface{}, error) {
//	arrRet, err := h.dao.GetHeroesByUid(uid)
//	if err != nil {
//		return nil, err
//	}
//	return arrRet, nil
//}
//
//// GetHeroByUidHtid retrieves a hero by UID and HTID
//func (h *HeroLogic) GetHeroByUidHtid(uid, htid string) (map[string]interface{}, error) {
//	return h.dao.GetHeroByUidHtid(uid, htid)
//}
//
//// GetArrHeroByHtid retrieves multiple heroes by HTID
//func (h *HeroLogic) GetArrHeroByHtid(uid string, htid []string) ([]map[string]interface{}, error) {
//	return h.dao.GetArrHeroByHtid(uid, htid)
//}
//
//// GetRecruitHero retrieves heroes in the recruit status by user ID
//func (h *HeroLogic) GetRecruitHero(uid string) ([]map[string]interface{}, error) {
//	return h.dao.GetHeroesByUidStatus(uid, HeroDef.STATUS_RECRUIT)
//}
//
//// GetHero retrieves a hero by HID
//func (h *HeroLogic) GetHero(hid string) (map[string]interface{}, error) {
//	return h.dao.GetByHid(hid, def.HERO_FIELDS)
//}
//
//// GetArrHero retrieves multiple heroes by a list of HIDs
//func (h *HeroLogic) GetArrHero(arrHid []string, arrField []string) ([]map[string]interface{}, error) {
//	if arrField == nil {
//		arrField = def.HERO_FIELDS
//	}
//	return h.dao.GetByArrHid(arrHid, arrField)
//}
//
//// RecruitForInit recruits a hero and initializes fields
//func (h *HeroLogic) RecruitForInit(uid, htid string, arrField map[string]interface{}) (string, error) {
//	if arrField == nil {
//		arrField = make(map[string]interface{})
//	}
//	arrField["status"] = def.STATUS_RECRUIT
//	return h.InsertFromTemplate(uid, htid, arrField)
//}
//
//// GetInitGoodwill returns initial goodwill values
//func (h *HeroLogic) GetInitGoodwill() map[string]interface{} {
//	return map[string]interface{}{
//		"exp":          0,
//		"level":        0,
//		"upgrade_time": 0,
//	}
//}
//
//// InsertFromTemplate inserts a hero from a template
//func (h *HeroLogic) InsertFromTemplate(uid, htid string, arrField map[string]interface{}) (string, error) {
//	if arrField == nil {
//		arrField = make(map[string]interface{})
//	}
//	arrField["htid"] = htid
//	arrField["uid"] = uid
//
//	// Default values for missing fields
//	if _, exists := arrField["curHp"]; !exists {
//		arrField["curHp"] = 0
//	}
//	if _, exists := arrField["level"]; !exists {
//		arrField["level"] = 1
//	}
//	if _, exists := arrField["rebirthNum"]; !exists {
//		arrField["rebirthNum"] = 0
//	}
//	if _, exists := arrField["exp"]; !exists {
//		arrField["exp"] = 0
//	}
//	if _, exists := arrField["stateId"]; !exists {
//		arrField["stateId"] = 0
//	}
//	if _, exists := arrField["upgrade_time"]; !exists {
//		arrField["upgrade_time"] = time.Now().Unix()
//	}
//	if _, exists := arrField["va_hero"]; !exists {
//		arrField["va_hero"] = make(map[string]interface{})
//		arrField["va_hero"].(map[string]interface{})["daimonApple"] = []interface{}{}
//	}
//
//	// Master hero specific logic
//	if HeroUtil.IsMasterHero(htid) {
//		if _, exists := arrField["va_hero"].(map[string]interface{})["master"]; !exists {
//			arrField["va_hero"].(map[string]interface{})["master"] = map[string]interface{}{
//				"transfer_num":          0,
//				"learned_normal_skills": []interface{}{},
//				"using_skill_time":      0,
//				"using_skill_num":       0,
//			}
//		}
//		transNum := arrField["va_hero"].(map[string]interface{})["master"].(map[string]interface{})["transfer_num"].(int)
//		arrDefaultRageSkill := btstore_get().MASTER_HEROES_TRANSFER[htid][transNum]["transfer_rageSkills"].ToArray()
//		rageSkill := int(arrDefaultRageSkill[0])
//		arrField["va_hero"].(map[string]interface{})["master"].(map[string]interface{})["learned_rage_skills"] = []interface{}{rageSkill}
//		arrField["va_hero"].(map[string]interface{})["master"].(map[string]interface{})["using_skill"] = rageSkill
//	}
//
//	// Add devil fruit items for hero
//	itemMgr := item.NewItemManager()
//	for pos, rebirthDmTid := range btstore_get().CREATURES[htid]["devilFruitSkill"] {
//		rebirthNum := rebirthDmTid[0]
//		if rebirthNum == 0 {
//			itemId := 0
//			if rebirthDmTid[1] != 0 {
//				itemId = itemMgr.AddItem(rebirthDmTid[1])[0]
//			}
//			arrField["va_hero"].(map[string]interface{})["daimonApple"].(map[string]interface{})[pos] = itemId
//		}
//	}
//
//	if itemMgr != nil {
//		itemMgr.Update()
//	}
//
//	// Set default arming state and goodwill
//	arrField["va_hero"].(map[string]interface{})["arming"] = def.ARMING_NO_ARMING
//	arrField["va_hero"].(map[string]interface{})["goodwill"] = h.GetInitGoodwill()
//
//	// Save hero and return ID
//	heroID, err := h.dao.Save(arrField)
//	if err != nil {
//		return "", err
//	}
//	return heroID, nil
//}
//
//// GetByHid retrieves a hero by HID
//func (h *HeroLogic) GetByHid(hid string) (map[string]interface{}, error) {
//	return h.dao.GetByHid(hid, def.HERO_FIELDS)
//}
//
//// GetMasterTopLevel retrieves heroes with the highest level
//func (h *HeroLogic) GetMasterTopLevel(offset, limit int, arrField []string) ([]map[string]interface{}, error) {
//	return h.dao.GetMasterTopLevel(offset, limit, arrField)
//}
//
//// GetMasterTopLevelUnstable retrieves heroes with the highest level (without sorting)
//func (h *HeroLogic) GetMasterTopLevelUnstable(offset, limit int, arrField []string) ([]map[string]interface{}, error) {
//	return h.dao.GetMasterTopLevelUnstable(offset, limit, arrField)
//}
//
//// GetMasterByLevel retrieves heroes of a specific level
//func (h *HeroLogic) GetMasterByLevel(level int, arrField []string, num int) ([]map[string]interface{}, error) {
//	return h.dao.GetMasterByLevel(level, arrField, num)
//}
